package com.vst.orm.search.jpa;

import java.util.List;
import javax.persistence.EntityManager;

import com.vst.orm.search.ExampleOptions;
import com.vst.orm.search.Filter;
import com.vst.orm.search.ISearch;
import com.vst.orm.search.SearchFacade;
import com.vst.orm.search.SearchResult;

public class JPASearchFacade
  implements SearchFacade
{
  protected JPASearchProcessor processor;
  protected EntityManager entityManager;
  
  public void setSearchProcessor(JPASearchProcessor searchProcessor)
  {
    this.processor = searchProcessor;
  }
  
  public void setEntityManager(EntityManager entityManager)
  {
    this.entityManager = entityManager;
  }
  
  public List search(ISearch search)
  {
    return this.processor.search(this.entityManager, search);
  }
  
  public List search(Class<?> searchClass, ISearch search)
  {
    return this.processor.search(this.entityManager, searchClass, search);
  }
  
  public int count(ISearch search)
  {
    return this.processor.count(this.entityManager, search);
  }
  
  public int count(Class<?> searchClass, ISearch search)
  {
    return this.processor.count(this.entityManager, searchClass, search);
  }
  
  public SearchResult searchAndCount(ISearch search)
  {
    return this.processor.searchAndCount(this.entityManager, search);
  }
  
  public SearchResult searchAndCount(Class<?> searchClass, ISearch search)
  {
    return this.processor.searchAndCount(this.entityManager, searchClass, search);
  }
  
  public Object searchUnique(ISearch search)
  {
    return this.processor.searchUnique(this.entityManager, search);
  }
  
  public Object searchUnique(Class<?> searchClass, ISearch search)
  {
    return this.processor.searchUnique(this.entityManager, searchClass, search);
  }
  
  public Filter getFilterFromExample(Object example)
  {
    return this.processor.getFilterFromExample(example);
  }
  
  public Filter getFilterFromExample(Object example, ExampleOptions options)
  {
    return this.processor.getFilterFromExample(example, options);
  }
}

